﻿var router = require('express').Router()
const fs = require('fs')

// 获取分组列表
router.get('/getGeojsonByCode', (req, res) => {
    let url = './geoJson/'
    const { folder = '', fileName = '' } = req.query
    if (folder) {
        url += folder + '/'
    }
    if (fileName) {
        url += fileName + '.geoJson'
    }
    fs.readFile(url, 'utf8', (err, data) => {
        if (err) {
            res.json({ code: 404, msg: err })
            return
        }
        res.json({ code: 200, data })
    })
})

module.exports = router
